package TestDS;

import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.ConcurrentHashMap;

import edu.usc.bg.base.ByteIterator;
import edu.usc.bg.base.Client;
import edu.usc.bg.base.DB;
import edu.usc.bg.base.DBException;
import edu.usc.bg.base.ObjectByteIterator;

import java.io.*;
import java.sql.*;
import java.util.*;


public class TestDSClient extends DB implements TestDSClientConstants {
	private boolean initialized = false;
	private Connection connection = null;
	private Properties props;
	private static final String DEFAULT_PROP = "";
	public boolean init() throws DBException 
	{
		if(initialized)
		{
			System.out.println("Client connection already initialized.");
		}
		else
		{
			props = getProperties();
			String connURL = props.getProperty(CONNECTION_URL, DEFAULT_PROP);
			String connUser = props.getProperty(CONNECTION_USER, DEFAULT_PROP);
			String connPwd = props.getProperty(CONNECTION_PASSWD, DEFAULT_PROP);
			String connDriver = props.getProperty(DRIVER_CLASS);
			try
			{
				Class.forName(connDriver);
				connection = DriverManager.getConnection(connURL,connUser,connPwd);
				System.out.println("Connected to MYSQL.");		
			}
			catch(Exception ex)
			{
				System.out.println("Exception: "+ ex.getMessage());
				return false;
			}
		}
		return true;
	}
	
	@Override
	public void cleanup(boolean warmup) throws DBException {
		try
		{
			if(!connection.isClosed())
				connection.close();
			else
				System.out.println("Connection already closed!");
				
		}
		catch(Exception ex)
		{
			System.out.println("Exception: "+ ex.getMessage());
		}
	}
	
	@Override
	public int viewTopKResources(int requesterID, int profileOwnerID, int k,
			Vector<HashMap<String, ByteIterator>> result) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	@Override
	public int postCommentOnResource(int commentCreatorID, int profileOwnerID, int resourceID, HashMap<String,ByteIterator> commentValues) 
	{
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insertEntity(String entitySet, String entityPK,
			HashMap<String, ByteIterator> values, boolean insertImage) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int viewProfile(int requesterID, int profileOwnerID,
			HashMap<String, ByteIterator> result, boolean insertImage,
			boolean testMode) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int listFriends(int requesterID, int profileOwnerID,
			Set<String> fields, Vector<HashMap<String, ByteIterator>> result,
			boolean insertImage, boolean testMode) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int viewFriendReq(int profileOwnerID,
			Vector<HashMap<String, ByteIterator>> results, boolean insertImage,
			boolean testMode) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int acceptFriend(int inviterID, int inviteeID) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int rejectFriend(int inviterID, int inviteeID) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int inviteFriend(int inviterID, int inviteeID) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int getCreatedResources(int creatorID,
			Vector<HashMap<String, ByteIterator>> result) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int viewCommentOnResource(int requesterID, int profileOwnerID,
			int resourceID, Vector<HashMap<String, ByteIterator>> result) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int delCommentOnResource(int resourceCreatorID, int resourceID,
			int manipulationID) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int thawFriendship(int friendid1, int friendid2) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public HashMap<String, String> getInitialStats() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int CreateFriendship(int friendid1, int friendid2) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void createSchema(Properties props) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public int queryPendingFriendshipIds(int memberID,
			Vector<Integer> pendingIds) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int queryConfirmedFriendshipIds(int memberID,
			Vector<Integer> confirmedIds) {
		// TODO Auto-generated method stub
		return 0;
	}
}